/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test;
import java.io.File;  
import java.io.FileWriter;  
import java.io.IOException;  
import java.io.Writer;  
import java.util.HashMap;  
import java.util.Map;  
  
import freemarker.template.Configuration;  
import freemarker.template.Template;  
import freemarker.template.TemplateException;  
  
/** 
 *  
 */  
  
public class m2 {  
    private static Configuration cfg = new Configuration();  
    public static void main(String[] args) throws TemplateException {  
     try {  
         cfg.setDirectoryForTemplateLoading(new File("templates"));
    Template template = cfg.getTemplate("t2.ftl");  
      
        // Build the data-model  
        Map root = new HashMap();  
        root.put("message", "Hello World!");  
          
        //OutputStreamWriter wr = new OutputStreamWriter(new OutputStream());  
        Writer w = new FileWriter(new File("templates/file2.html"));  
        template.process(root, w);  
        //template.dump(System.out);  
          
          
  
    } catch (IOException e) {  
    // TODO Auto-generated catch block  
    e.printStackTrace();  
    }  
    }  
}  
